# coding=utf-8
"""
修复track status
"""
import sys
import os

base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_dir)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "base.settings")

from common.lottery.cyclical.model import ORDER_MODEL
from common.lottery.cyclical.abstract.order import try_stop_track_index
from common.lottery.model import TrackIndex


def fix_track():
    items = TrackIndex.query.filter(TrackIndex.status == 1).all()
    for item in items:
        order_table = ORDER_MODEL[item.activity_type]
        try_stop_track_index(order_table, item.track_id)


if __name__ == "__main__":
    fix_track()
